package controller;

import java.util.List;
import java.util.UUID;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import pojo.User;
import service.UserManager;
import service.factory.UserManagerFactory;

@Controller
public class UserController {
	private UserManager manager;
	
	public UserController(){
		manager = UserManagerFactory.getInstance();
	}
	
	@RequestMapping(value="/addUser", method=RequestMethod.POST)
	public String addUser(User user){
		manager.addUser(user);
		return "redirect:listAll";
	}
	
	@RequestMapping(value="/listAll")
	public String listAll(Model model){
		List<User> users = manager.findAll();
		model.addAttribute("users", users);
		
		return "list";
	}

}
